package com.demo.student;

import com.demo.common.model.Student;
import com.demo.common.model.User;
import com.jfinal.core.Controller;
import com.jfinal.validate.Validator;

public class StudentValidator extends Validator {

    @Override
    protected void validate(Controller controller) {
        validateRequiredString("student.studentid", "studentidMsg", "请输入学生学号!");
        validateRequiredString("student.studentname", "studentnameMsg", "请输入学生姓名!");
    }

    @Override
    protected void handleError(Controller controller) {
        controller.keepModel(Student.class);

        String actionKey = getActionKey();
        if (actionKey.equals("/student/save"))
            controller.render("add.html");
        else if (actionKey.equals("/student/update"))
            controller.render("edit.html");
    }
}
